
<div class="wrapper">
	<a href="<?php echo site_url('grading/subjects/create'); ?>" class="btn btn-add">
    	<span class="btn-icon plus-icon"></span>
		<?php echo lang('subject_add_button'); ?>
    </a>
    <a href="#" class="btn btn-delete" id="del_button">
    	<span class="btn-icon delete-icon"></span>
		<?php echo lang('subject_delete_button'); ?>
    </a>
    <?php echo form_open('grading/subjects/delete',array('id'=>'form_subject')); ?>
	<table class="table-grid">
    	<thead>
        	<tr>
            	<th class="action-width"><input type="checkbox" id="select-all" /></th>
            	<th><?php echo lang('subject_code'); ?></th>
                <th><?php echo lang('subject_name'); ?></th>
                <th><?php echo lang('subject_description'); ?></th>
				<th><?php echo lang('subject_category'); ?></th>
                <th class="action-width"><?php echo lang('subject_action'); ?></th>
            </tr>
        </thead>
        <tbody>
        <?php $i=0; ?>
        <?php foreach($subjects as $s) : ?>
        	<tr class="<?php echo ($i%2) ? 'odd' : 'even'; ?>">
            	<td class="align-center"><input type="checkbox" name="subject_id[]" value="<?php echo $s->id; ?>" /></td>
            	<td class="align-center"><?php echo $s->code; ?></td>
                <td class="align-center"><?php echo $s->name; ?></td>
                <td class="align-justify"><?php echo $s->description; ?></td>
				<td class="align-center"><?php echo $s->category->name; ?></td>
                <td class="align-center">
                	<a href="<?php echo site_url('grading/subjects/edit/'.$s->id); ?>" class="btn btn-edit" title="<?php echo lang('subject_edit_button'); ?>"><span class="btn-icon edit-icon"></span></a>
                	<a href="<?php echo site_url('grading/subjects/delete/'.$s->id); ?>" class="btn btn-delete" title="<?php echo lang('subject_delete_button'); ?>"><span class="btn-icon delete-icon"></span></a>
                </td>
            </tr>
            <?php $i++; ?>
        <?php endforeach; ?>
        </tbody>
    </table>
    <?php echo form_close(); ?>
    <?php echo $page; ?>
</div>
<script>
$('#select-all').click(function(){
	$("input[type='checkbox']").attr('checked', $(this).is(':checked'));   
});


$('.btn').click(function(){
	$.facebox.settings.closeImage = '<?php echo image_path('facebox/closelabel.png'); ?>';
	$.facebox({
		ajax		 : $(this).attr('href')
	});
	return false;
});

$(document).ready(function() {
<?php if($this->session->flashdata('msg')) : ?>
	$.notificationBox("<?php echo $this->session->flashdata('msg_title'); ?>","<?php echo $this->session->flashdata('msg'); ?>");
<?php endif; ?>

	$('#del_button').click(function(){
		
		if($('#form_subject input:checked').is(':checked'))
		{
			$('#form_subject').submit();
		} else {
		}
		
		return false;
	});
});
</script>